updating oE canonical_path

canonical_path

include filesys.e 
namespace filesys 
public function canonical_path(sequence path_in, integer directory_given = 0, 
        case_flagset_type case_flags = AS_IS) 

returns the full path and file name of the supplied file name.

Parameters:
  1. path_in : A sequence. This is the file name whose full path you want.
  2. directory_given : An integer. This is zero if path_in is to be interpreted as a file specification otherwise it is assumed to be a directory specification. The default is zero.
  3. case_flags : An integer. This is a combination of flags. AS_IS = Includes no flags TO_LOWER = If passed will convert the part of the path not affected by other case flags to lowercase. CORRECT = If passed will correct the parts of the filepath that exist in the current filesystem in parts of the filesystem that is case insensitive. This should work on Windows or SMB mounted volumes on Unix and all OS X filesystems.

TO_LOWER = If passed alone the entire path is converted to lowercase. or_bits(TO_LOWER,CORRECT) = If these flags are passed together the the part that exists has the case of that of the filesystem. The part that does not is converted to lower case. TO_SHORT = If passed the elements of the path that exist are also converted to their Windows short names if avaliable.

Returns:

A sequence, the full path and file name.

Comments:
  • The supplied file/directory does not have to actually exist.
  • path_in can be enclosed in quotes, which will be stripped off.
  • If path_in begins with a tilde '~' then that is replaced by the contents of $HOME in Unix platforms and %HOMEDRIVE%%HOMEPATH% in Windows.
  • In Windows all '/' characters are replaced by '\' characters.
  • Does not (yet) handle UNC paths or Unix links.
Example 1:
-- Assuming the current directory is "/usr/foo/bar"  
res = canonical_path("../abc.def") 
-- res is now "/usr/foo/abc.def" 
Example 2:
-- res is "C:\Program Files" on systems that have that directory. 
res = canonical_path("c:\pRoGrAm FiLeS", CORRECT) 
-- on Windows Vista this would be "c:\Program Files" for Vista uses lowercase for its drives. 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu